<admintpl file="header"/>
</head>
<body>

<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:U('indexmy/login')}">本站用户</a></li>
        <li class="active"><a href="{:U('indexmy/adduser')}">添加用户</a></li>
    </ul>
    <form id="f_tj" method="post" class="form-horizontal js-ajax-form">

        <fieldset>
            <div class="control-group">
                <label class="control-label">用户名:</label>
                <div class="controls">
                    <input type="text" name="user_login">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">密码:</label>
                <div class="controls">
                    <input type="password" name="user_pass">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">邮箱:</label>
                <div class="controls">
                    <input type="text" name="user_email">
                </div>
            </div>
        </fieldset>
        <div class="form-actions">
            <button id="btn_tj" class="btn btn-primary js-ajax-submit">添加</button>
            <a class="btn" href="javascript:history.back(-1);">返回</a>
            <span id="mess" style="color: red;"></span>

        </div>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    $('#mess').hide();
    $('#btn_tj').click(function () {
        var $data = $('#f_tj').serialize();
        $.post("{:U('indexmy/add_user')}", $data, function (o) {
            console.log(o);

            if (o == 333) {
                $('#mess').show();
                $('#mess').html('此用户已存在，请重新添加！');
                location.href = "{:U('indexmy/adduser')}";
            } else {
                if (o == 1111) {
                    $('#mess').show();
                    $('#mess').html('添加成功！');
                    location.href = "{:U('indexmy/login')}";
                } else {
                    $('#mess').show();
                    $('#mess').html('用户名，密码,邮箱，不能为空！');
                    location.href = "{:U('indexmy/adduser')}";
                }
            }


        });
        return false;
    })

</script>
</body>